package com.technoorbit.vbreakup;


import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class GossipsActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gossips);
    }
    public void SetListAdapter()
    { 
    	try {
    	Bundle extras = getIntent().getExtras();
    	String userID = extras.getString("UserID");
    	String Type = extras.getString("TYPE");
    	String postID = extras.getString("postID");
		
    	final ArrayList<CustomList> listAdapter=JSONfunctions.ParseJsonMapData(String.format(URLOptions.str_GosipsUrl,userID,postID),Type);
		
		if	(listAdapter!=null){
		Context ctx = getApplicationContext();
		Resources res = ctx.getResources();
		final ListView list;
		
		//set image here
		TypedArray icons = res.obtainTypedArray(R.array.arrow_icon);
		list=(ListView)findViewById(R.id.gossipslistItems);
		list.setAdapter(new CustomListAddapter(ctx, R.layout.categories,listAdapter, icons));
		
		list.setOnItemClickListener(new OnItemClickListener()
     	{
     	public void onItemClick(AdapterView<?> arg0, View v, int position, long id)
     	{
        	//String parentIDOnList=(String) list.getItemAtPosition(position);
     		int id1=listAdapter.get(position).getID();
     		Intent intent=new Intent(GossipsActivity.this, DetailsBaseActivity.class);
			intent.putExtra("id", id1);
			startActivity(intent);
     	 }
     
     	});
		}
		
    	}
    	catch (Exception e) {
    		e.printStackTrace();
        
    	}
    }
    
}